package com.sc.mapper;

import java.io.IOException;

import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import com.sc.bean.SpendSecond;

public class StaffPartMapper extends Mapper<LongWritable, Text, Text, SpendSecond> {

	Text outKeyName = new Text();
	Text outKeyCity = new Text();
	FloatWritable outMoney = new FloatWritable();
	SpendSecond outValue =  new SpendSecond();
	
	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, SpendSecond>.Context context)
			throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		String line = value.toString();
		String[] word = line.split("    ");
		outKeyName.set(word[0]);
		outKeyCity.set(word[1]);
		outMoney.set(Float.parseFloat(word[3]));
		
		outValue.setName(outKeyName);
		outValue.setCity(outKeyCity);
		outValue.setMoney(outMoney);
		context.write(outKeyName, outValue);
	}
}
